package cn.itcast.com.IO.SerializStream;

import java.io.*;

public class demo01 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        SerializeClass obj = new SerializeClass(10,6.6);
        //序列化流
        ObjectOutputStream objos = new ObjectOutputStream(new FileOutputStream("t.tmp"));
        objos.writeObject(obj);
        objos.close();

        //反序列化
        ObjectInputStream objoos = new ObjectInputStream(new FileInputStream("t.tmp"));
        Object o = objoos.readObject();
        System.out.println(o);
        objoos.close();

    }

}
class SerializeClass implements Serializable{
    int i;
    double j;

    public SerializeClass(int i, double j) {
        this.i = i;
        this.j = j;
    }


    @Override
    public String toString() {
        return "SerializeClass{" +
                "i=" + i +
                ", j=" + j +
                '}';
    }
}